<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="utf-8">
    <title>lib/options.js - YUIDoc</title>
    <link rel="stylesheet" href="https://yui-s.yahooapis.com/3.9.1/build/cssgrids/cssgrids-min.css">
    <link rel="stylesheet" href="../assets/vendor/prettify/prettify-min.css">
    <link rel="stylesheet" href="../assets/css/main.css" id="site_styles">
    <link rel="icon" href="../assets/favicon.ico">
    <script src="https://yui-s.yahooapis.com/combo?3.9.1/build/yui/yui-min.js"></script>
</head>
<body class="yui3-skin-sam">

<div id="doc">
    <div id="hd" class="yui3-g header">
        <div class="yui3-u-3-4">
                <h1><img src="../assets/css/logo.png" title="YUIDoc" width="117" height="52"></h1>
        </div>
        <div class="yui3-u-1-4 version">
            <em>API Docs for: 0.10.0</em>
        </div>
    </div>
    <div id="bd" class="yui3-g">

        <div class="yui3-u-1-4">
            <div id="docs-sidebar" class="sidebar apidocs">
                <div id="api-list">
                    <h2 class="off-left">APIs</h2>
                    <div id="api-tabview" class="tabview">
                        <ul class="tabs">
                            <li><a href="#api-classes">Classes</a></li>
                            <li><a href="#api-modules">Modules</a></li>
                        </ul>
                
                        <div id="api-tabview-filter">
                            <input type="search" id="api-filter" placeholder="Type to filter APIs">
                        </div>
                
                        <div id="api-tabview-panel">
                            <ul id="api-classes" class="apis classes">
                                <li><a href="../classes/CLI.html">CLI</a></li>
                                <li><a href="../classes/DocBuilder.html">DocBuilder</a></li>
                                <li><a href="../classes/DocParser.html">DocParser</a></li>
                                <li><a href="../classes/DocView.html">DocView</a></li>
                                <li><a href="../classes/Files.html">Files</a></li>
                                <li><a href="../classes/Help.html">Help</a></li>
                                <li><a href="../classes/Main.html">Main</a></li>
                                <li><a href="../classes/Options.html">Options</a></li>
                                <li><a href="../classes/Server.html">Server</a></li>
                                <li><a href="../classes/Utils.html">Utils</a></li>
                                <li><a href="../classes/YUIDoc.html">YUIDoc</a></li>
                            </ul>
                
                
                            <ul id="api-modules" class="apis modules">
                                <li><a href="../modules/yuidoc.html">yuidoc</a></li>
                            </ul>
                        </div>
                    </div>
                </div>
            </div>
        </div>
        <div class="yui3-u-3-4">
                <div id="api-options">
                    Show:
                    <label for="api-show-inherited">
                        <input type="checkbox" id="api-show-inherited" checked>
                        Inherited
                    </label>
            
                    <label for="api-show-protected">
                        <input type="checkbox" id="api-show-protected">
                        Protected
                    </label>
            
                    <label for="api-show-private">
                        <input type="checkbox" id="api-show-private">
                        Private
                    </label>
                    <label for="api-show-deprecated">
                        <input type="checkbox" id="api-show-deprecated">
                        Deprecated
                    </label>
            
                </div>
            
            <div class="apidocs">
                <div id="docs-main">
                    <div class="content">
<h1 class="file-heading">File: lib/options.js</h1>

<div class="file">
    <pre class="code prettyprint linenums">
/**
 * Copyright (c) 2011, Yahoo! Inc. All rights reserved.
 * Code licensed under the BSD License:
 * https://github.com/yui/yuidoc/blob/master/LICENSE
 */
&#x27;use strict&#x27;;

YUI.add(&#x27;options&#x27;, function (Y) {

    var path = require(&#x27;path&#x27;);

    /**
     * Handles argument parsing
     * @module yuidoc
     * @class Options
     */

    /**
     * Parses arguments and returns an Object of config options
     * @method Options
     * @param {Array} args Arguments to parse
     * @return {Object} The config object
     */
    Y.Options = function (args) {
        var options = {
            port: 3000,
            nocode: false
        };

        while (args.length &gt; 0) {
            var v = args.shift();
            // options.* defined in ./builder.js
            switch (v) {
            case &#x27;--lint&#x27;:
                options.lint = true;
                options.parseOnly = true;
                options.writeJSON = false;
                options.quiet = true;
                break;
            case &#x27;--debug&#x27;:
                Y.applyConfig({
                    debug: true,
                    filter: &#x27;debug&#x27;
                });
                break;
            case &#x27;--charset&#x27;:
                Y.charset = args.shift() || &#x27;utf8&#x27;;
                Y.log(&#x27;Setting default charset to &#x27; + Y.charset, &#x27;yuidoc&#x27;, &#x27;warn&#x27;);
                break;
            case &#x27;-c&#x27;:
            case &#x27;--config&#x27;:
            case &#x27;--configfile&#x27;:
                options.configfile = args.shift();
                break;
            case &#x27;-e&#x27;:
            case &#x27;--extension&#x27;:
                options.extension = args.shift();
                break;
            case &#x27;-x&#x27;:
            case &#x27;--exclude&#x27;:
                options.exclude = args.shift();
                break;
            case &#x27;-v&#x27;:
            case &#x27;--version&#x27;:
                console.error(Y.packageInfo.version);
                process.exit(1);
                break;
            case &#x27;--project-version&#x27;:
                options.version = args.shift();
                break;
            case &#x27;-N&#x27;:
            case &#x27;--no-color&#x27;:
                Y.config.useColor = false;
                options.nocolor = true;
                break;
            case &#x27;-D&#x27;:
            case &#x27;--no-delete-out&#x27;:
                options.nodeleteout = true;
                break;
            case &#x27;-C&#x27;:
            case &#x27;--no-code&#x27;:
                options.nocode = true;
                break;
            case &#x27;-n&#x27;:
            case &#x27;--norecurse&#x27;:
                options.norecurse = true;
                break;
            case &#x27;-S&#x27;:
            case &#x27;--selleck&#x27;:
                options.selleck = true;
                break;
            case &#x27;-V&#x27;:
            case &#x27;--view&#x27;:
                options.dumpview = true;
                break;
            case &#x27;-p&#x27;:
            case &#x27;--parse-only&#x27;:
                options.parseOnly = true;
                break;
            case &#x27;-o&#x27;:
            case &#x27;--outdir&#x27;:
                options.outdir = args.shift();
                break;
            case &#x27;-t&#x27;:
            case &#x27;--themedir&#x27;:
                options.themedir = args.shift();
                break;
            case &#x27;--server&#x27;:
                options.server = true;
                var a = args.shift();
                var p = parseInt(a, 10);
                if (isNaN(p) || !p) {
                    if (a) {
                        args.unshift(a);
                    }
                    Y.log(&#x27;Failed to extract port, setting to the default :3000&#x27;, &#x27;warn&#x27;, &#x27;yuidoc&#x27;);
                } else {
                    options.port = p;
                }
                break;
            case &#x27;-h&#x27;:
            case &#x27;--help&#x27;:
                Y.showHelp();
                break;
            case &#x27;-H&#x27;:
            case &#x27;--helpers&#x27;:
                var list = args.shift();
                if (list) {
                    options.helpers = list.split(&#x27;,&#x27;);
                } else {
                    throw (&#x27;Failed to pass a helper file.&#x27;);
                }
                break;
            case &#x27;-T&#x27;:
            case &#x27;--theme&#x27;:
                var theme = args.shift();
                options.themedir = path.join(__dirname, &#x27;../&#x27;, &#x27;themes&#x27;, theme);
                break;
            case &#x27;-q&#x27;:
            case &#x27;--quiet&#x27;:
                options.quiet = true;
                break;
            case &#x27;--syntaxtype&#x27;:
                options.syntaxtype = args.shift();
                break;
            case &#x27;--tab-to-space&#x27;:
                options.tabtospace = parseInt(args.shift(), 10);
                if (typeof options.tabtospace === &#x27;number&#x27;) {
                    options.tabspace = &#x27;&#x27;;
                    for (var s = 0; s &lt; options.tabtospace; s++) {
                        options.tabspace += &#x27; &#x27;;
                    }
                }
                break;
            case &#x27;--no-sort&#x27;:
                options.dontsortfields = true;
                break;
            default:
                if (!options.paths) {
                    options.paths = [];
                }
                if (v &amp;&amp; v.indexOf(&#x27;-&#x27;) === 0) {
                    throw (&#x27;Unknown option: &#x27; + v);
                }
                options.paths.push(v);
            }
        }

        if (options.quiet) {
            Y.applyConfig({
                debug: false
            });
        }

        return options;
    };

});

    </pre>
</div>
                    </div>
                </div>
            </div>
        </div>
    </div>
</div>
<script src="../assets/vendor/prettify/prettify-min.js"></script>
<script>prettyPrint();</script>
<script src="../assets/js/yui-prettify.js"></script>
<script src="../assets/../api.js"></script>
<script src="../assets/js/api-filter.js"></script>
<script src="../assets/js/api-list.js"></script>
<script src="../assets/js/api-search.js"></script>
<script src="../assets/js/apidocs.js"></script>
</body>
</html>
